#*******************************************************************
#* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        *
#*                                                                 *
#*  NOTE      = 协议分析主框架模块
#*  DATE      = 
#*******************************************************************

#共通参数
include         ../../lib/apmmodule/Makefile_comm.mk

#正式版
ifeq ($(COMM_RELEASE), 1)
CFLAGS          = -DFRFRAME_DO_UDP
else
CFLAGS          = -DFRDBG_CT_DBG -DFRFRAME_DO_UDP
endif

CFLAGS          += $(CFLAGS_EXT) `xml2-config --cflags`
CFLAGS          += $(CFLAGS_UTEST)

#-DFRDBG_CAP_IN                     收到的数据包信息出力到debug日志
#-DFRDBG_CAP_DO                     数据包->task信息出力到debug日志
#-DFRDBG_CT_DBG                     CT调试用输出
#-DFRDBG_NO_LOG                     没有log出力
#-DFRDBG_MODULE_STAT_SHOW           显示模块统计信息
#-DFRDBG_DROP_REPEAT_CT             删除重复ct包

#-DFRFRAME_DO_UDP               解析udp数据包

#protoc代码路径
PROTOC_PATH     = ../../../../../common/protoc/src/client

PCAP_CFLAGS     = -I/usr/include/pcap
PCAPLIB         = -lpcap

LNET_CFLAGS     = -I/usr/local/include -D_BSD_SOURCE -D__BSD_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H
LNETLIB         = -lnet

LIBS_CFLAGS     = $(PCAP_CFLAGS) $(LNET_CFLAGS)
CFLAGS_EXE      =
ifeq ($(enable_centos7), 1)
CFLAGS_EXE     += -Wl,--export-dynamic
endif

LIBS            = -lnids $(PCAPLIB) $(LNETLIB) -lgthread-2.0 -lnsl -levent -levent_pthreads -lssl -ljson-c -ldaq -lsfbpf -ldaq_static
LIBS            += -lrt -lm -ldl -lzlog -lzmq -luuid -lprotobuf $(XML2LIB) `xml2-config --libs`

ifeq ($(enable_dbg_rdel), 0) 
    LIBS += -lluajit-5.1
endif
ifeq ($(enable_dbg_rdel), 5)  
    LIBS += -lluajit-5.1
endif

LIBS            += $(LIBS_EXT)

INCLUDES        = -I. -I$(LIB_I_APM_COMM) -I$(LIB_I_APM_MODULE) -I$(LIB_I_APM_SHM) -I$(PROTOC_PATH)

#获取代码名称
SRC_FRAME       = $(wildcard fr*.c) 
OBJS_FRAME      = $(patsubst %.c,%.o,$(SRC_FRAME)) $(PROTOC_PATH)/client.pb.o


#生成主程序
TARGET_BIN      = apm

all: $(TARGET_BIN)

.c.o:
	$(CX) -c $< $(CFLAGS) $(INCLUDES) $(LIBS_CFLAGS) -o $@

.cc.o:
	$(CX) -c $< $(CFLAGS) $(INCLUDES) $(LIBS_CFLAGS) -o $@

$(TARGET_BIN):  $(OBJS_FRAME)
	$(CX) $(CFLAGS) $(CFLAGS_EXE) -o $@ $(OBJS_FRAME) $(LIB_A_APM_MODULE) $(LIB_A_APM_COMM) $(LIB_A_APM_SHM) $(LDFLAGS) $(LIBS)

install:
	rm -f $(COMM_DIST_DIR_BIN)/$(TARGET_BIN); mkdir -p $(COMM_DIST_DIR_BIN); cp $(TARGET_BIN) $(COMM_DIST_DIR_BIN)/.

uninstall:
	rm -f $(COMM_DIST_DIR_BIN)/$(TARGET_BIN)

clean:
	rm -f *.o *.log core.* *~ $(TARGET_BIN) $(PROTOC_PATH)/*.o

# EOF
